/**
 * File：   花园请求api.
 */
import {post} from './post'
function testProx() {
  return post('http://wdhdebug.22ca.com/admin/index.php?act=api&op=index', {})
}
// 上传临时图片（识花）
function uploadTmpImg(base64Data) {
  return post('/index.php?act=image&op=upLoadFile', {base64_img: base64Data})
}
// 识花
function distinguish(imgUrl) {
  return post('/index.php?act=image&op=image_submit', {url: imgUrl})
}
// 获取百科收录的所有植物列表
function getPlantList(page, pageSize, keyword, rang) {
  return post('/index.php?act=garden_a&op=selectplantOne', {page: page, pageSize: pageSize, m_name: keyword, m_pinyin: rang})
}
// 获取百科信息
function getWikiInfo(id) {
  return post('/index.php?act=flower_baike&op=get_baike', {m_id: id})
}
// 根据百科获取商品列表 type: 3买花 1037租花
function getGoodsByWiki({city_id, m_id, page, pageSize, type}) {
  return post('/index.php?act=flower_baike&op=get_flower_goods', {city_id: city_id, m_id: m_id, page: page, pageSize: pageSize, type: type})
}
// 获取养护信息
function getTutorialInfo(id) {
  return post('/index.php?act=flower_baike&op=get_tutorial', {m_id: id})
}
// 获取我的花园列表(不包含共享花园)
function getGardenList() {
  return post('/index.php?act=garden&op=index', {})
}
// 获取我的花园列表(包含共享花园)
function getAllGardenList() {
  return post('/index.php?act=garden&op=memberAllGarden', {})
}
function delGarden(id) {
  return post('/index.php?act=garden&op=delGarden', {g_id: id})
}
// 删除共享花园
function delShareGarden(id) {
  return post('/index.php?act=garden&op=delshareGarden', {sg_id: id})
}
// 获取已删除的花园列表 parentGardenId: 选填
function getGardenDeletedList(parentGardenId) {
  return post('/index.php?act=garden&op=delGardenList', {sg_id: parentGardenId})
}
// 获取已删除的共享花园列表
function getShareGardenDeletedList() {
  return post('/index.php?act=garden&op=delshareGardenList', {})
}
// 恢复已删除的花园
function restoreDeletedGarden(id) {
  return post('/index.php?act=garden&op=recGarden', {g_id: id})
}
// 恢复已删除的共享花园
function restoreDeletedShareGarden(id) {
  return post('/index.php?act=garden&op=recshareGarden', {sg_id: id})
}
// 添加花园
function addGarden({type, area_id, city_id, cover_img, garden_name, province_id, start_time, end_time, remark}) {
  return post('/index.php?act=garden&op=addGarden', {type, area_id, city_id, cover_img, garden_name, province_id, start_time, end_time, remark})
}
// 获取花园信息
function getGardenInfo(id) {
  return post('/index.php?act=garden&op=showEditGarden', {g_id: id})
}
// 更新花园信息
function updateGardenInfo({g_id, area_id, city_id, cover_img, garden_name, province_id, remark}) {
  return post('/index.php?act=garden&op=editGarden', {g_id, area_id, city_id, cover_img, garden_name, province_id, remark})
}
// 获取花园任务信息
function getGardenTaskInfo(id) {
  return post('/index.php?act=garden&op=showGardenTask', {g_id: id})
}
// 获取花园顶部轮播
function getGardenBannerList() {
  return post('/index.php?act=garden&op=getGardenAdvimg', {})
}
/**
 * 更新花园任务
 * @param g_id 花园id
 * @param is_tip 是否提醒： 0 不提醒 1 提醒
 * @param ta_interval 提醒日期间隔
 * @param ta_interval_type 提醒日期间隔单位 1天 2周 3月 4年
 * @param ta_note 养护信息
 * @param ta_time 提醒时间
 * @param ta_title 标题
 * @returns {Promise}
 */
function updateGardenTask({g_id, is_tip, ta_interval, ta_interval_type, ta_note, ta_time, ta_title}) {
  return post('/index.php?act=garden&op=gardenTask', {g_id, is_tip, ta_interval, ta_interval_type, ta_note, ta_time, ta_title})
}
// 获取花园里的植物列表
function getPlantListByGarden(g_id, page, pageSize) {
  return post('/index.php?act=garden&op=mygarPlant', {g_id, page, pageSize})
}
// 获取我的所有植物列表 state: 0曾经有 1 现有 2所有
function getMyPlantList(state, type, page, pageSize) {
  return post('/index.php?act=garden&op=myallPlant', {tab_type: state, auth_type: type, page: page, pageSize: pageSize})
}
// 获取植物属性
function getPlantAttr() {
  return post('/index.php?act=garden&op=selectplantTwo', {})
}
/** 添加植物到花园
 * @param g_id 花园id
 * @param m_id 植物id
 * @param ba_id 载体id
 * @param di_id 基质id
 * @param en_id 场景id
 * @param flower_name 植物名
 * @param flower_image 植物图
 * @returns {Promise}
 */
function addPlantToGarden({g_id, m_id, h_id, growth_status, ba_id, di_id, en_id, flower_name, flower_image, start_time, end_time, m_baike_url}) {
  return post('/index.php?act=garden&op=addplant', {g_id, m_id, h_id, growth_status, ba_id, di_id, en_id, flower_name, flower_image, start_time, end_time, m_baike_url})
}
// 删除花园里的植物
function delPlantInGarden(id) {
  return post('/index.php?act=garden&op=delPlant', {o_id: id})
}
// 恢复植物
function recoverPlant(id) {
  return post('/index.php?act=garden&op=recPlant', {o_id: id})
}
// 获取花园里的植物信息
function getPlantInfo(id) {
  return post('/index.php?act=garden&op=showSiglePlant', {o_id: id})
}
// 获取植物详细信息
function getPlantDetailInfo(id) {
  return post('/index.php?act=garden&op=plantBasicInfo', {o_id: id})
}
/** 更新花园里的植物信息
 * @param o_id 植物id
 * @param growth_status 成长状态
 * @param ba_id 载体id
 * @param di_id 基质id
 * @param en_id 场景id
 * @param flower_name 植物名
 * @param flower_image 植物图
 * @returns {Promise}
 */
function updatePlantInfo({h_id, growth_status, ba_id, di_id, en_id, flower_image, flower_name, o_id, start_time, end_time}) {
  return post('/index.php?act=garden&op=editplant', {h_id, growth_status, ba_id, di_id, en_id, flower_image, flower_name, o_id, start_time, end_time})
}
// 获取植物养护信息
function getMaintainList(id, season) {
  return post('/index.php?act=garden&op=curing', {o_id: id, season: season})
}
/**
 * 更新提醒设置
 * @param o_id 用户的植物id
 * @param param_type 事件类型 1:是否提醒 2设置时隔天数 3:提醒时间 4:养护事项, 5是否重复提醒
 * @param season 季节代码, 1春2夏3秋4冬
 * @param ta_interval 提醒执行间隔时间
 * @param ta_interval_type 提醒执行间隔时间单位, 1天 2周 3月 4年
 * @param ta_note 养护事项
 * @param ta_time 提醒时间
 * @param ta_tip 是否提醒
 * @param ta_type 任务类型, 1浇水 2施肥 3换盆 4修剪 5病虫害 6日照 7其他
 * @returns {Promise}
 */
function updateMaintainInfo({o_id, param_type, season, ta_interval, ta_interval_type, ta_note, ta_time, ta_tip, ta_type, is_loop}) {
  return post('/index.php?act=garden&op=setCuring', {o_id, param_type, season, ta_interval, ta_interval_type, ta_note, ta_time, ta_tip, ta_type, is_loop})
}
// 恢复单个提醒的默认设置
function resumeSetting(plantId, season, action) {
  return post('/index.php?act=garden&op=revCuring', {o_id: plantId, season: season, ta_type: action})
}
// 恢复全部提醒的默认设置
function resumeAllSetting(plantId, season) {
  return post('/index.php?act=garden&op=revAllCuring', {o_id: plantId, season: season})
}
/***
 * 添加成长日记
 * @param o_id 植物id
 * @param behavior 点亮行为
 * @param content 内容
 * @param growth_status 成长状态
 * @param pictures 图片
 * @returns {Promise}
 */
function addGrowthNote({o_id, h_id, behavior, content, growth_status, pictures}) {
  return post('/index.php?act=garden&op=addGrowthInfo', {o_id, h_id, behavior, content, growth_status, pictures})
}
/***
 * 更新成长日记
 * @param g_id 成长日记id
 * @param behavior 点亮行为
 * @param content 内容
 * @param growth_status 成长状态
 * @param pictures 图片
 * @returns {Promise}
 */
function updateGrowthNote({g_id, h_id, behavior, content, growth_status, pictures}) {
  return post('/index.php?act=garden&op=editGrowthInfo', {g_id, h_id, behavior, content, growth_status, pictures})
}
// 获取成长日记列表
function getGrowthNoteList(id, page, pageSize) {
  return post('/index.php?act=garden&op=plantGrowthInfo', {o_id: id, page: page, pageSize: pageSize})
}

// 获取全部任务 type: 0:今日 1本周 2:本月 3上月以前
function getTaskList({is_share, state, type}) {
  return post('/index.php?act=garden&op=timeTask', {is_share, state, type})
}
// 获取花园里的全部任务
function getTaskListByGarden(id) {
  return post('/index.php?act=garden&op=gardenPlantTask', {g_id: id})
}
// 获取全部任务（按行为归类）
function getTaskGroupByAction() {
  return post('/index.php?act=garden&op=behTask', {})
}
// 根据任务id列表获取植物列表
function getPlantListByTask(taskIdList) {
  return post('/index.php?act=garden&op=growthStatusList', {mt_ids: taskIdList})
}
// 一键完成任务 statusObjList : [{o_id: '', growth_status: ''}, ...]
function dealBatchTask(statusObjList, taskIdList) {
  return post('/index.php?act=garden&op=completeTask', {growth_status: statusObjList, mt_ids: taskIdList})
}
// 忽略任务
function cancleTask(id) {
  return post('/index.php?act=garden&op=ignTask', {mt_id: id})
}
function getWeatherInfo(cityId) {
  return post('/index.php?act=weather&op=get_weather', {area_id: cityId})
}
// 获取共享花园列表
function getShareGardenList(page, pageSize) {
  return post('/index.php?act=garden&op=shareGarden', {page, pageSize})
}
// 获取共享花园的子花园列表
function getShareGardenChildrenList(parentGardenId) {
  return post('/index.php?act=garden&op=gardenSonList', {sg_id: parentGardenId})
}
// 添加共享子花园
function addShareGardenChildren({sg_id, area_id, city_id, cover_img, garden_name, province_id, remark}) {
  return post('/index.php?act=garden&op=addGardenSon', {sg_id, area_id, city_id, cover_img, garden_name, province_id, remark})
}
// 获取可添加为花园成员的列表
function getFansListUnAddToGarden(gardenId, page, pageSize) {
  return post('/index.php?act=garden&op=get_fans_list', {sg_id: gardenId, page: page, pageSize: pageSize})
}
// 获取共享花园的成员列表
function getGardenMemberList(gardenId, page, pageSize) {
  return post('/index.php?act=garden&op=sgMemList', {sg_id: gardenId, page: page, pageSize: pageSize})
}
// 添加共享花园成员
function addGardenMember(gardenId, memberIdList) {
  return post('/index.php?act=garden&op=addSgMem', {sg_id: gardenId, member_ids: memberIdList})
}
// 删除共享花园的成员
function delGardenMember(id) {
  return post('/index.php?act=garden&op=deleteMem', {gm_id: id})
}
/**
 * 未分配园丁的植物列表
 * @param sg_id 共享花园id
 * @param g_id 共享花园子花园id
 * @param page
 * @param pageSize
 * @returns {Promise}
 */
function getUnDistributePlantList({sg_id, g_id, page, pageSize}) {
  return post('/index.php?act=garden&op=unassignPlants', {sg_id, g_id, page, pageSize})
}
// 为花园成员分配植物
function memberAddDistributePlant(gardenMemberId, plantIdList) {
  return post('/index.php?act=garden&op=assingMemPlant', {gm_id: gardenMemberId, o_id: plantIdList})
}
// 取消植物已分配的养护员
function delPlantDistribute(plantId) {
  return post('/index.php?act=garden&op=revokeMemPlant', {o_id: plantId})
}
// 获取花园成员已分配的植物列表
function getMemberDistributedPlantList({member_id, sg_id, page, pageSize}) {
  return post('/index.php?act=garden&op=getcuringFlower', {member_id, sg_id, page, pageSize})
}
// 获取共享花园信息
function getShareGardenInfo(id) {
  return post('/index.php?act=garden&op=showeditsg', {sg_id: id})
}
// 更新共享花园信息
function updateShareGardenInfo({sg_id, area_id, city_id, cover_img, garden_name, province_id, end_time, start_time, remark}) {
  return post('/index.php?act=garden&op=editshareGarden', {sg_id, area_id, city_id, cover_img, garden_name, province_id, end_time, start_time, remark})
}
export {
  testProx,
  uploadTmpImg,
  distinguish,
  getPlantList,
  getWikiInfo,
  getGoodsByWiki,
  getTutorialInfo,
  getGardenList,
  getAllGardenList,
  delGarden,
  delShareGarden,
  getGardenDeletedList,
  getShareGardenDeletedList,
  restoreDeletedGarden,
  restoreDeletedShareGarden,
  addGarden,
  getGardenInfo,
  updateGardenInfo,
  getGardenTaskInfo,
  getGardenBannerList,
  updateGardenTask,
  getPlantListByGarden,
  getMyPlantList,
  getPlantAttr,
  addPlantToGarden,
  delPlantInGarden,
  recoverPlant,
  getPlantInfo,
  getPlantDetailInfo,
  updatePlantInfo,
  getMaintainList,
  updateMaintainInfo,
  resumeSetting,
  resumeAllSetting,
  addGrowthNote,
  updateGrowthNote,
  getGrowthNoteList,
  getTaskList,
  getTaskListByGarden,
  getTaskGroupByAction,
  getPlantListByTask,
  dealBatchTask,
  cancleTask,
  getWeatherInfo,
  getShareGardenList,
  getShareGardenChildrenList,
  addShareGardenChildren,
  getFansListUnAddToGarden,
  getGardenMemberList,
  addGardenMember,
  delGardenMember,
  getUnDistributePlantList,
  memberAddDistributePlant,
  delPlantDistribute,
  getMemberDistributedPlantList,
  getShareGardenInfo,
  updateShareGardenInfo
}